package com.ruoyi.system.controller;

import java.util.List;

import com.ruoyi.common.annotation.Anonymous;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JifenUserPointsAccount;
import com.ruoyi.system.service.IJifenUserPointsAccountService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2025-05-14
 */
@Controller
@RequestMapping("/system/account")
public class JifenUserPointsAccountController extends BaseController
{
    private String prefix = "system/account";

    @Autowired
    private IJifenUserPointsAccountService jifenUserPointsAccountService;

    @RequiresPermissions("system:account:view")
    @GetMapping()
    public String account()
    {
        return prefix + "/account";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @ApiOperation("获取account的接口")
    @RequiresPermissions("system:account:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JifenUserPointsAccount jifenUserPointsAccount)
    {
        startPage();
        List<JifenUserPointsAccount> list = jifenUserPointsAccountService.selectJifenUserPointsAccountList(jifenUserPointsAccount);
        return getDataTable(list);
    }


//    /**
//     * 查询【请填写功能名称】列表
//     */
//    @Anonymous
//    @ApiOperation("獲取积分的操作")
//    @PostMapping("/getPoints")
//    @ResponseBody
//    public int  getPoints( String userid,int  points)
//    {
//
//         jifenUserPointsAccountService.addAvailablePoints(userid,points);
//         return  1;
//    }
//
//


    /**
     * 导出【请填写功能名称】列表
     */
    @Anonymous

    @RequiresPermissions("system:account:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JifenUserPointsAccount jifenUserPointsAccount)
    {
        List<JifenUserPointsAccount> list = jifenUserPointsAccountService.selectJifenUserPointsAccountList(jifenUserPointsAccount);
        ExcelUtil<JifenUserPointsAccount> util = new ExcelUtil<JifenUserPointsAccount>(JifenUserPointsAccount.class);
        return util.exportExcel(list, "【请填写功能名称】数据");
    }

    /**
     * 新增【请填写功能名称】
     */
    @Anonymous
    @ApiOperation("新增")
    @RequiresPermissions("system:account:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @Anonymous
    @ApiOperation("新增保存")
    @RequiresPermissions("system:account:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JifenUserPointsAccount jifenUserPointsAccount)
    {
        return toAjax(jifenUserPointsAccountService.insertJifenUserPointsAccount(jifenUserPointsAccount));
    }

    /**
     * 修改【请填写功能名称】
     */

    @Anonymous
    @ApiOperation("修改")
    @RequiresPermissions("system:account:edit")
    @GetMapping("/edit/{accountId}")
    public String edit(@PathVariable("accountId") Long accountId, ModelMap mmap)
    {
        JifenUserPointsAccount jifenUserPointsAccount = jifenUserPointsAccountService.selectJifenUserPointsAccountByAccountId(accountId);
        mmap.put("jifenUserPointsAccount", jifenUserPointsAccount);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @Anonymous
    @ApiOperation("修改保存")
    @RequiresPermissions("system:account:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JifenUserPointsAccount jifenUserPointsAccount)
    {
        return toAjax(jifenUserPointsAccountService.updateJifenUserPointsAccount(jifenUserPointsAccount));
    }

    /**
     * 删除【请填写功能名称】
     */
    @Anonymous
    @ApiOperation("删除")
    @RequiresPermissions("system:account:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jifenUserPointsAccountService.deleteJifenUserPointsAccountByAccountIds(ids));
    }
}
